package com.newmacys.user;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.BaseCommandController;

public class ViewUserController extends BaseCommandController {

	private UserConfigBean userConfigBean;
	
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Map<String, Object> model = new HashMap<String, Object>();
		
		model.put("props", userConfigBean);
		request.setAttribute("props", userConfigBean);
		
//		TilesContainer container = TilesAccess.getContainer(
//		        request.getSession().getServletContext());
//		
//		container.render(userConfigBean.getTilesView(), request, response);
		
		return new ModelAndView(userConfigBean.getTilesView(), model);
	}

	public void setUserConfigBean(UserConfigBean userConfigBean) {
		this.userConfigBean = userConfigBean;
	}

}
